import Vue  from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    vue:null,
  },
  mutations: {
    /**
     * @function 实例化vue并且保存到公共状态管理
     * @method newVue
     */
    newVue(state,vue){
        state.vue=vue
    },
    /**
     * @function 路由跳转
     * @method goto
     * @param {*} state 
     * @param {string} router 
     */
    goto(state,router){
      if(state.vue.data&&state.vue.data.animation)(clearInterval(state.vue.data.animation))
      state.vue.$router.push(router)
    },

    /**
     * @name 返回上一级
     * @method back
     */
    back(){
      window.history.back()
    }


  },
  actions: {
    setApp({commit}, platform) {
      commit('SET_APP', platform);
    },
  },
  getters: {
    getApp: (state) => state.platform
  }
})